<?php

namespace App\Api;

use App\Http\Controllers\Controller;
use App\Models\Honorary;
use Illuminate\Http\Request;

class HonoraryController extends Controller
{

    public function index()
    {
        $honoraries = Honorary::all();
        return $honoraries;
    }


    public function store(Request $request, Honorary $honorary)
    {
        $request->validate([
            'title' => ['required'],
            'content' => ['required']
        ]);
        $honorary->create($request->input());
        return $this->message('添加成功');
    }


    public function show(Honorary $honorary)
    {
        //
    }


    public function edit(Honorary $honorary)
    {
        //
    }


    public function update(Request $request, Honorary $honorary)
    {
        $request->validate([
            'title' => ['required'],
            'content' => ['required']
        ]);
        $honorary->update($request->input());
        $honorary->save();
        return $this->message('修改成功');
    }


    public function destroy(Honorary $honorary)
    {
        $honorary->delete();
        return $this->message('删除成功');
    }
}
